<?php
/**
 * Shortcuts
 * This functions are shortcuts to call some standard process
 *
 * @author Patrice Ferlet <metal3d@copix.org>
 * @package utils 
 * @license http://opensource.org/licenses/lgpl-3.0.html GNU Lesser General Public License Version 3.0 (LGPLv3)
*/


/**
 * Return the GET or POST value
 *
 * @param string name
 * @param mixed default if null
 * @return string value
 *
 */
function _request ($varname,$default){
    return PRequest::instance()->get($varname,$default);
}


/**
 *
 * @param string $configfilename (default null)
 * @return PKernel instance
 */
function _kernel($configfilename=NULL){
    return PKernel::instance($configfilename);
}

/**
 * Returns parsed configuration
 *
 * @return PXML_structure
 */
function _config(){
    return _kernel()->getConfiguration();
}

/**
 * Log system
 * @param mixed $message
 * @param string $type ("dump", "display", "log", "dumpToFile")
 */
function _log($message,$type="dump"){
    PDebug::log($message,$type);
}


function _obj($datas=NULL){
    return new PStandardObject($datas);
}


/**
 * Set display
 *
 * @param PStandardObject $display
 * @return PActionReturn
 */

function _display(PStandardObject $display){
    return new PActionReturn(PActionReturn::DISPLAY,$display);
}

/**
 * Get DB
 *
 * @param string connectionname
 * @return PDB
 */

function _db($connectionname="default"){
    return PDB::instance($connectionname); 
}

/**
* Get DAO
* 
* @param string tablename
* @param string connection_name
* @return PDAO object
*/
function _dao($tablename, $conn="default"){
    return new PDAO($tablename, $conn);
}


/**
* Get DBRecord
* 
* @param string tablename
* @param string connection_name
* @return PDAO object
*/
function _record($tablename, $conn="default"){
    return PDBRecord::instance($tablename, $conn);
}


/**
* Get resource path
*
* @param sting resource_path
* @return string resource_path_corrected
*/
function _resource($path){
    return PUrl::resource($path);
}
